import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

import { ROOT_MU } from './mutation-type'

import moduleA from './moduleA'
import moduleB from './moduleB'

let state = {
  rootState: 'rootState'
}

let mutations = {
  [ROOT_MU](state, payload) {
    state.rootState = state.rootState + '-' + payload.payload2 + payload.payload1
  }
}

let actions = {
  rootAc({ commit }, payload) {
    commit(ROOT_MU, payload)
  }
}

let getters = {
  rootGetter(state, getters) {
    console.log(state)
    console.log(getters)
  },
  // rootGetter2:function(state){
  //   return function(payload){
  //     return state.rootState + '-' + payload
  //   }
  // }
  rootGetter2: state => payload => state.rootState + '-' + payload
}



export default new Vuex.Store({
  state,
  mutations,
  actions,
  getters,
  modules: {
    moduleA,
    moduleB
  }
})
